package com.manjusaka.create6.builder1;

/**
 * 建造者模式--简化多参数构造类。
 * 类中有静态的内部类
 * final 无法改变 类--无法被继承 参数--无法改变 方法--无法重写
 * 要点：静态+final的内部类
 */
public class BuilderDesignPattern {
    private int id;
    private int age;
    private int name;

    public int getId() {
        return id;
    }

    public int getAge() {
        return age;
    }

    private BuilderDesignPattern(Bulider bulider) {
        id = bulider.id;
        age = bulider.age;
    }

    private class InTest
    {
        public InTest()
        {
            System.out.println(name);
        }
    }


    public static final class Bulider {
        private int id;
        private int age;

        public Bulider setId(int id) {
            this.id = id;
            return this;
        }

        public Bulider setAge(int age) {
            this.age = age;
            return this;
        }

        public BuilderDesignPattern build() {
            return new BuilderDesignPattern(this);
        }
    }
}

class Test {
    public static void main(String[] args) {
        BuilderDesignPattern.Bulider bulider = new BuilderDesignPattern.Bulider();
        BuilderDesignPattern build = bulider.setAge(10).setId(1).build();
        System.out.println(build.toString());
    }
}
